import { createSlice, PayloadAction } from '@reduxjs/toolkit';

export interface ConsoleState {
  commands: string[];
}

const initialState: ConsoleState = {
  commands: [],
};

const consoleSlice = createSlice({
  name: 'console',
  initialState,
  reducers: {
    updateConsole: (state, action: PayloadAction<string[]>) => {
      state.commands = action.payload;
    },
    addCommand: (state, action: PayloadAction<string>) => {
      state.commands.push(action.payload);
    },
    clearConsole: (state) => {
      state.commands = [];
    },
  },
});

export const { updateConsole, addCommand, clearConsole } = consoleSlice.actions;

export default consoleSlice.reducer;

